Imports Microsoft.VisualBasic

Namespace My
    Public Class StringLengthValidator
        Inherits RegularExpressionValidator

        Private Sub StringLengthValidator_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            Me.ValidationExpression = "^[\s\S]{" + Me.Length.ToString() + ",}$"
            'ValidationExpression="^[\s\S]{6,}$" 
        End Sub

        Public Property Length() As Integer
            Get
                Return ViewState("Length")
            End Get
            Set(ByVal value As Integer)
                ViewState("Length") = value
            End Set
        End Property
    End Class

End Namespace
